<?php

namespace app\index\controller\token;

use app\index\model\UM as UM;
use app\index\service\CoinActivityService;
use ShidianUtil\Thinkphp\Response\ApiResponse;
use think\APP;
use think\Request as Request;

/**
 * CoinActivity 控制器
 * Class CoinActivity
 * @package app\index\controller\token;
 * @link https://www.kancloud.cn/manual/thinkphp6_0/1037509
 * @see \app\index\validate\token\CoinActivity
 */
class CoinActivity
{
    // 请求参数
    private Request $request;

    // service
    private CoinActivityService $service;

    public function __construct(Request $request, CoinActivityService $coinActivityService)
    {
        $this->request = $request;
        $this->service = $coinActivityService;
    }

    /**
     * 详情
     * @param UM|null $user
     * @return ApiResponse
     * @url /token/coin_activity/read
     */
    public function read(UM $user): ApiResponse
    {
        $request = $this->request;

        return ApiResponse::success($this->service->read($user, $request->param()));
    }
}
